<!DOCTYPE html>
<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>收货地址</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no, maximum-scale=1.0" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link href="../assets/mobile/comm.css" rel="stylesheet" type="text/css" />
	<link href="../assets/mobile/login.css" rel="stylesheet" type="text/css" />
	<script src="../assets/js/mobile/jquery190.js" type="text/javascript"></script>
	<link rel="stylesheet" href="../assets/mobile/top.css">
	<link rel="stylesheet" href="../assets/mobile/aui.css">
	<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/local.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
</head>
<body style="background:#fff;">
<style>
#header{
	border:none;
}
#header,#header .titlebar{
	background-color:#DD3E96;
	color:#fff !important;
}
#header h1{
	color:#fff !important;
}
.pull-left,.pull-right{
	color:#fff !important;
}	
</style>


<style>
.registerCon select{
	background: #FFF none repeat scroll 0% 0%;
	border: 5px solid #DDD;
	color: #CCC;
	border-radius: 5px;
	padding: 0px 5px;
	display: inline-block;
	position: relative;
	font-size: 16px;
	height: 50px;
	width: 101%;
}
.registerCon .loading{
	padding-top: 20px;
	color: #999;
}
.registerCon .form{
	display:none;
}
</style>

<section id="wrapper" style="margin-top:0px !important; top:0px !important;bottom:0px !important;margin-bottom:0px !important;padding-bottom:0px !important;">
<div>
 			<div class="block10"></div>
		<div class="aui-content aui-card">       
        <div class="aui-form">
			<div class="aui-input-row">
                <span class="aui-input-addon">省</span>
                <input name="sheng" type="text" class="aui-input"/>
            </div>

            <div class="aui-input-row">
                <span class="aui-input-addon">市</span>
                <input name="shi" type="text" class="aui-input"/>
            </div>
            <div class="aui-input-row">
                <span class="aui-input-addon">县</span>
                <input name="xian" type="text" class="aui-input"/>
            </div>
            <div class="aui-input-row">
                <span class="aui-input-addon">详细地址</span>
                <input name="jiedao" type="text" class="aui-input"/>
            </div>
            <div class="aui-input-row">
                <span class="aui-input-addon">邮政编码</span>
                <input name="youbian" type="text" class="aui-input"/>
            </div>
			<div class="aui-input-row">
                <span class="aui-input-addon">收货人</span>
                <input name="shouhuoren" type="text" class="aui-input"/>
            </div>
			<div class="aui-input-row">
                <span class="aui-input-addon">手机号</span>
                <input name="mobile" type="text" class="aui-input"/>
            </div>
            <div class="aui-btn-row">
				<input style="margin-right:20px;" name="submit" class="aui-btn aui-btn-block aui-btn-success common-btn" id="btn_consignee_save" value="保存" title="保存提交" type="submit"> 	
            </div>

        </div>
    </div>


 <div class="block20"></div>
</div>
</section>
<link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
<script type="text/javascript">
apiready = function(){
$(function(){
    var userinfo = localData.get('userinfo');
	var userinfo = JSON.parse(userinfo);
	var address_id = localData.get('address_id');
	if(address_id != undefined && typeof userinfo == 'object' && address_id != ''){
		$.ajax({
			type : 'get',
			dataType:'jsonp',
			url : config.url+'/app.php?act=getOneaddress&id='+address_id+'&uid='+userinfo['uid'],
			success : function(res){
				if(res['status'] == 1){
					$('input[name=sheng]').val(res['sheng']);
					$('input[name=shi]').val(res['shi']);
					$('input[name=xian]').val(res['xian']);
					$('input[name=jiedao]').val(res['jiedao']);
					$('input[name=youbian]').val(res['youbian']);
					$('input[name=shouhuoren]').val(res['shouhuoren']);
					$('input[name=mobile]').val(res['mobile']);
				}else{
					$.PageDialog.fail('获取数据失败');
				}
			}
		});
		 $('input[name=submit]').click(function(){
		      var provice = $('input[name=sheng]').val();
		      if(provice == ''){
		          $.PageDialog.fail("请输入省份");
		          return false;
		      }
	       var city = $('input[name=shi]').val();
	                     if(city == ''){
                 $.PageDialog.fail("请输入城市名称");
                 return false;
             }
	        var area = $('input[name=xian]').val();
	                     if(area == ''){
                 $.PageDialog.fail("请输入区域");
                 return false;
             }
	        var jiedao = $('input[name=jiedao]').val();
	              if(jiedao == ''){
                 $.PageDialog.fail("请输入详细地址");
                 return false;
             }
	        var shouhuoren = $('input[name=shouhuoren]').val();
	          if(shouhuoren == ''){
                 $.PageDialog.fail("请输入收货人");
                 return false;
             }
	         var youbian = $('input[name=youbian]').val();
	          if(youbian == ''){
                 $.PageDialog.fail("请输入邮编");
                 return false;
             }
             if(!checkZipcode(youbian)){
                 $.PageDialog.fail("邮编格式不正确");
                 return false;
             }
	         var mobile = $('input[name=mobile]').val();
	          if(mobile == ''){
                 $.PageDialog.fail("请输入手机号码");
                 return false;
             }
             if(!checkMobile(mobile)){
                 $.PageDialog.fail("手机号码格式不正确");
                 return false;
             }
             api.showProgress({title:'正在保存'});
		      $.ajax({
		          type : 'post',
		          dataType:'json',
		          url : config.url+"/app.php?act=updateaddress&uid="+userinfo['uid']+'&id='+address_id,
		          data : {
		        	 'send' : true,
		             'province' : provice,
		             'city' : city,
		             'area' : area,
		             'truename' : shouhuoren,
		             'zipcode' : youbian,
		             'mobile' : mobile,
		             'jiedao' : jiedao
		          },
		          success : function(res){
		        	  api.hideProgress();
		              if(res['status'] == 1){
		            	  localData.set('add_address_ok',1);
		                  $.PageDialog.ok("<s></s>"+res['msg']);
		                  setTimeout(function(){
		                	  localData.remove('address_id');
		                	  appClose('add_address',api);
		                	  appClose('user_add',api);
		                  },2000);
		              }else{
		                  $.PageDialog.fail(res['msg']);
		              }
		          }
		      });
		 });
	}else{
		randomSwitchBtn('login',api);
	}
});
};
</script>
</body>
</html>